package org.zfes.snowier.cloud.zbss.pmp.router.service.pub;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.ComboboVo;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.core.data.TreeVo;
import org.zfes.snowier.core.data.ZTreeVo;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.pmp.model.PmpRequires;
import org.zfes.snowier.cloud.zbss.pmp.service.IPmpRequiresService;
@Controller("org.zfes.snowier.cloud.zbss.pmp.router.service.pub.pmpRequiresController") 
@RequestMapping("/pmp/service/pub/pmpRequires")
public class PmpRequiresController extends BaseController {
	
	@Autowired
	private IPmpRequiresService pmpRequiresService;

	
    @RequestMapping(value="/loadPmpRequiresById", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpRequiresById(Long id){
    	 Optional<PmpRequires> requires = pmpRequiresService.loadPmpRequiresById(id);
		return ajaxQuery("requires",requires);
    }
    
    
    @RequestMapping(value="/loadRequiresZTreeVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadRequiresZTreeVo(Long projectId){
    	List<ZTreeVo> ops = pmpRequiresService.loadRequiresZTreeVo(projectId);
		return ops;
    }
    
    @RequestMapping(value="/loadPmpRequiresTreeVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpRequiresTreeVo(Long projectId){
		Optional<TreeVo> ops = pmpRequiresService.loadRequiresTreeVo(projectId);
		return ajaxQuery("treeVo",ops);
    }
    @RequestMapping(value="/loadRequiresComboboVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadRequiresComboboVo(Long projectId,Boolean firstEmpty){
		 List<ComboboVo>  vo=pmpRequiresService.loadComboboVo(projectId,firstEmpty);
	    return ajaxQuery("comboboVo", vo);
    }

    @RequestMapping(value="/loadPmpRequiresDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpRequiresDataSet(@RequestParam Map<String,Object> params){
        DataSet dataSet=  pmpRequiresService.loadPmpRequiresDataSet(params);
        return ajaxQuery("dataSet", dataSet);
    }
}